#include "predef.h"

#include "ioset1.h"
#include "public.h"
#include "sysdata.h"
#include "meterdata.h"
#include "fileset1.h"
#include "StdPeriph_Driver.h"
#include "flashinfo.h"

extern struct stSYSCON stsyscon;
extern struct stSYSCONIO stsysconio;

extern strFlashInfo FlashInfo;
extern const strFData FData;
extern const sFileSet FileSet;


void
InitDisp ()
{
  LCD->CR3 = 0;
  LCD->CR2 = 0x70 | (FData.DftSet.MSet.DispCR2 << 1);	//3.3v, internal source
#ifdef		_USE_RTC_
  LCD->FRQ = 0x04;
#else
  if (_bOnLine_)
    {
      LCD->FRQ = 0x20;
    }
  else
    {
      LCD->FRQ = 0x08;
    }
#endif
  LCD->CR4 = 0x03;		//1/8 duty, 1/4 bias
  LCD->PM[0] = 0b11111111;
	 LCD->PM[1] = 0b00001111;
	 LCD->PM[2] = 0b10000000;
   LCD->PM[3] = 0b11001110;
  LCD->CR3 = 0x40 | (FData.DftSet.MSet.DispCR3 & 7);	//lcd en
}


void
CloseDisp (void)
{
  LCD->CR3 = 0x00;
  LCD->CR2 = 0x00;
  LCD->CR4 = 0x00;
}

int
UpdateDisp (void)
{
  u8 n;
	static u8 i = 0 ;
  extern u8 *@tiny tpChar;
#ifdef		_TEST_DISP_
  TestDisp ();
#endif
  LCD->CR4 = 0x03;
  tpChar = stsyscon.DispData;
  n = 0;
  do
    {
      LCD->RAM[n] =  *tpChar++;
    }
  while (++n < 21);
  n = 0;
  LCD->CR4 = 0x07;
  do
    {
      LCD->RAM[n] =   *tpChar++;
    }
  while (++n < 21);
}
